home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / maximus / mxms_161.zip / FOSSIL.C < prev    next >
C/C++ Source or Header  |  1991-07-28  |  4KB  |  217 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*    Fossil.c      :Fossil routines for MaxMail                            */
  4. /*                                                                          */
  5. /****************************************************************************/
  6.  
  7. #include "MaxMail.h"
  8. #include <Bios.h>
  9.  
  10.  
  11. /* Higher level fossil routines */
  12.  
  13. union REGS r;
  14. struct SREGS sr;
  15.  
  16. #define  COUNTDOWN  1024 * 40
  17.  
  18. /* Initialize fossil */
  19. int _pascal FossilInit(void)
  20. {
  21.  
  22.   r.h.ah = 0x4;
  23.   r.x.dx = Pport;
  24.   r.x.bx = 0;
  25.  
  26. /*  r.x.cx = FP_OFF(&break_flag);
  27.   sr.es = FP_SEG(&break_flag); */
  28.  
  29.   int86x(0x14,&r,&r,&sr);        /* Call Fossil */
  30.  
  31.   if (0x1954 != r.x.ax)
  32.     return FALSE;
  33.   else if (r.h.bl < 0x18 || r.h.bh < 5) {
  34.     logit("Level 5 FOSSIL req'd",'!');
  35.     return FALSE;
  36.   }
  37.   else {        /* Diddle the handshaking stuff */
  38.    r.h.al = (byte) (prm.handshake_mask | 0xf0);
  39.    r.h.ah = 0x0f;
  40.    r.x.dx = Pport;
  41.    int86(0x14,&r,&r);        /* Call Fossil */
  42.    return TRUE;
  43.   }
  44. }
  45.  
  46. /* De-initialize fossil */
  47. void _pascal FossilDeInit(void)
  48. {
  49.    _asm  {
  50.       mov   ah,05
  51.       mov   dx,Pport
  52.       int   14h
  53.    }
  54. }
  55.  
  56.  
  57. /* Purge Fossil buffer. If Mode is TRUE, purge input buffer, FALSE
  58.     purge outout buffer */
  59.  
  60. void _pascal FossPurgeBuff(int mode)
  61. {
  62.  
  63.    if (mode) {        /* purge input buffer */
  64.       _asm  {
  65.          mov   ah,0ah
  66.          mov   dx,Pport
  67.          int   14h
  68.       }
  69.    }
  70.    else {        /* Purge output buffer */
  71.       _asm  {
  72.          mov   ah,09h
  73.          mov   dx,Pport
  74.          int   14h
  75.       }
  76.    }
  77.  
  78. /* Turn on break */
  79.  
  80.    FossBreak(10);
  81.    delay_s(1);
  82. }
  83.  
  84. void _pascal FossFlow(byte mask)
  85. {
  86.    _asm  {
  87.       mov   ah,0fh
  88.       mov   dx,Pport
  89.       mov   al,mask
  90.       int   14h
  91.    }
  92. }
  93.  
  94. /* Toggle DTR, if mode = TRUE, raise DTR. If mode = FALSE lower DTR */
  95. void _pascal FossDtr(int mode)
  96. {
  97.    _asm  {
  98.       mov   dx,Pport
  99.       mov   ax,mode
  100.       mov   ah,06h
  101.       int   14h
  102.    }
  103. }
  104.  
  105. unsigned _pascal FossMdmStatus(void)
  106. {
  107.    int   x;
  108.  
  109.    _asm {
  110.       mov   ah,03
  111.       mov   dx,Pport
  112.       int   14h
  113.       mov   x,ax
  114.    }
  115.    return(x);
  116. }
  117.  
  118. /* Return a keystroke. Check local keyboard first, then fossil */
  119. unsigned _pascal FossGetCh(void)
  120. {
  121.    int   x;
  122.  
  123.    _asm {
  124.       mov   ah,01h
  125.       int   16h
  126.       jz    start1
  127.       mov   ah,0h
  128.       int   16h
  129.       jmp   leave1
  130.  
  131.    start1:
  132.       mov   ax,0ffffh
  133.       test  [IsLocal],-1
  134.       jnz   leave1
  135.  
  136.       mov   ah,0ch
  137.       mov   dx,Pport
  138.       int   14h
  139.       cmp   ax,0ffffh
  140.       je    leave1
  141.       mov   ah,2
  142.       mov   dx,Pport
  143.       int   14h
  144.  
  145.    leave1:
  146.       mov   x,ax
  147.    }
  148.    return(x);
  149. }
  150.  
  151. /* Transmit a character to fossil with no wait */
  152.  
  153. void _pascal FossSendCh(byte chr)
  154. {
  155.    int x;
  156.    unsigned y;
  157.  
  158.    _asm {
  159.       mov   dx,Pport
  160.       mov   al,chr
  161.       mov   ah,0bh
  162.       int   14h
  163.       mov   x,ax
  164.    }
  165.    y = 0;
  166.    while (!x) {
  167.       check_carrier();
  168.       if (++y > COUNTDOWN) 
  169.          aborterror(DEADMODEM,NULL);
  170.       _asm {
  171.          mov   dx,Pport
  172.          mov   al,chr
  173.          mov   ah,0bh
  174.          int   14h
  175.          mov   x,ax
  176.       }
  177.    }
  178. }
  179.  
  180. /* Transmit a string to fossil */
  181. void _pascal FossSendStr(char *strng)
  182. {
  183.    char *p;
  184.  
  185.    if (IsLocal)
  186.       return;
  187.  
  188.    p = strng;
  189.    while (*p) {
  190.       FossSendCh(*p);
  191.       p++;
  192.    }
  193. }
  194.  
  195. void _pascal FossBreak(int tsecs)
  196. {
  197.    if (prm.flags & FLAG_break_clr) {
  198.  
  199.       _asm {
  200.          mov   dx,Pport
  201.          mov   al,1        /* Send break */
  202.          mov   ah,1ah
  203.          int   14h
  204.       }
  205.  
  206.       delay_ms(100 * tsecs);
  207.  
  208.       _asm {
  209.          mov   dx,Pport
  210.          mov   al,0        /* Stop break */
  211.          mov   ah,1ah
  212.          int   14h
  213.       }
  214.    }
  215. }
  216.  
  217.